import request from '@/utils/request'

// 基于账号实现登录
export const userAccountLogin = ({ account, password }) => {
  return request({
    method: 'post',
    url: '/login',
    data: { account, password }
  })
}

// 获取手机验证码
export const userMobileLoginMsg = (mobile) => {
  return request({
    method: 'get',
    url: '/login/code',
    data: { mobile }
  })
}

// 基于手机和验证码实现登录
export const userMobileLogin = ({ mobile, code }) => {
  return request({
    method: 'post',
    url: '/login/code',
    data: { mobile, code }
  })
}

// 注册小兔鲜账号时，验证用户名是否已经存在
export const userCheckAccount = (account) => {
  return request({
    method: 'get',
    url: '/register/check',
    data: { account }
  })
}

// 注册账号时发送验证码
export const userQQPatchCode = (mobile) => {
  return request({
    method: 'get',
    url: '/register/code',
    data: { mobile }
  })
}

// 注册新账号提交表单接口
// unionId通过QQ的SDK获取
export const userQQPatchLogin = (unionId, form) => {
  return request({
    method: 'post',
    url: '/login/social/' + unionId + '/complement',
    data: form
  })
}

// 绑定手机号
export const userQQBindLogin = (unionId, mobile, code) => {
  return request({
    method: 'post',
    url: '/login/social/bind',
    data: { unionId, mobile, code }
  })
}

// 获取QQ绑定的时候短信验证码
export const userQQBindCode = (mobile) => {
  return request({
    method: 'get',
    url: '/login/social/code',
    data: { mobile }
  })
}

// 第三方QQ登录
export const userQQLogin = (unionId, source = 6) => {
  return request({
    method: 'post',
    url: '/login/social',
    data: { unionId, source }
  })
}
